﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="SC_Incurred.aspx.cs"
    Inherits="SCMain" EnableEventValidation="False" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>北大资源集团 - 成本核算系统</title>
    <script src="/Resource/jquery/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="/js/freezehelper.js" type="text/javascript"></script>
    <script src="/js/mask.js" type="text/javascript"></script>
    <link href="/Resource/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <%--<script type="text/javascript" >    document.onLoad = showMask();</script>--%>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table width="100%" class='HeadTable'>
                <tr>
                    <td>
                        <div class='showTitle'>
                            <%= ProjectName%>
                            项目<%= StageName %>成本拆分明细</div>
                    </td>
                    <td align="right">
                        <asp:Button ID="btnSave" runat="server" Text="保存" OnClick="btnSave_Click" />
<%--                        <asp:Button ID="btnExport" runat="server" Text="导出" OnClick="btnExport_Click" />
                        <input value="导入" onclick='OpenImportDig()'  type="button"/>--%>
                        <asp:Button ID="btnClose" runat="server" Text="关闭" OnClientClick='window.close();return false;' />
                        <%--<input  value="关闭" onclick='window.close();'/>--%>
                    </td>
                </tr>
            </table>
            <div id="tt" runat="server"></div>
            <table id="MainTable" runat="server" freezerownum="6" freezecolumnnum="7" rules="all"
                style="border: 1px dotted #C0C0C0; width: 100%" class="mainTable">
                <tr>
                    <td rowspan="6" style="width: 80px;">
                        <div class='table_tb_e'>
                            科目编码</div>
                    </td>
                    <td rowspan="6" style="width: 80px;">
                        <div class='table_tb_e'>
                            成本科目</div>
                    </td>
                    <td align="center" colspan="4" rowspan="2">
                        实际已发生成本
                    </td>
                    <td rowspan="6" style="width: 80px;">
                        <div class='table_tb_e'>
                            校核</div>
                    </td>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td rowspan="4">
                        <div class='table_tb_e'>
                            合同金额（万元）</div>
                    </td>
                    <td rowspan="4">
                        <div class='table_tb_e'>
                            设计变更（万元）</div>
                    </td>
                    <td rowspan="4">
                        <div class='table_tb_e'>
                            签证洽商（万元）</div>
                    </td>
                    <td rowspan="4" style="width: 100px;">
                        <div class='table_tb_e'>
                            结算金额（万元）</div>
                    </td>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
            </table>
            <input id="hidEType" type="hidden" runat="server" />
            <input id="hidParams" type="hidden" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--    <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" DynamicLayout="true"
        AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div style="position: absolute; left: 400px; top: 250px;">
                <span style="color: Red">正在处理中，请等待... </span>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>--%>
    <%--    <div id="mask" class="mask">
        正在加载。。。</div>--%>
    <%--    <asp:Button ID="btnDoEvent" runat="server" CausesValidation="False" OnClick="btnDoEvent_Click"
        Text="Do" Visible="False" />--%>
    <div id="footer">
        Copyright © 2014 北大方正集团
    </div>
    <script type="text/javascript">

        function GethidETypeId() {
            return '<%=hidEType.ClientID  %>';
        }
        function GethidParamsId() {
            return '<%=hidParams.ClientID  %>';
        }
        function InitChangeImage() {
            $(".left").attr("src", "./images/close.gif");
            $(".right").attr("src", "./images/open.gif");
            $(".left").attr("title", "上一组业态");
            $(".right").attr("title", "下一组业态");

            $(".left").click(function () {
                var cur = $(this).parent().attr("curr");
                if (cur == 0) {
                    alert("已经是最左");
                    return;
                }
                $("#" + GethidETypeId()).val("ChangeIndex");
                $("#" + GethidParamsId()).val(cur - 1);
                DoServerRequest();
            });
            $(".right").click(function () {
                var cur = $(this).parent().attr("curr");
                var total = $(this).parent().attr("total");
                if (cur >= total - 1) {
                    alert("已经是最右");
                    return;
                }
                $("#" + GethidETypeId()).val("ChangeIndex");
                $("#" + GethidParamsId()).val(cur + 1);
                DoServerRequest();
            });
        }

        function OpenImportDig()
        {
        var id=getUrlParam('id');
                    var url ="ImportTable.aspx?"+id;
            if (window.showModalDialog) {
                win = window.showModalDialog(url, window, "dialogTop=100;dialogLeft=100;dialogWidth=200;dialogHeight=200");
            }
            else {
                win = window.open(url + id, "dialogTop=0;dialogLeft=0;dialogWidth=" + screen.width + ";dialogHeight=" + screen.height);
            }
        }
        function getUrlParam(name)
        {
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r!=null) return unescape(r[2]); return null; //返回参数值
        } 
        $(document).ready(function () {

            // showMask();


            //            document.onreadystatechange = function () {
            //                if (document.readyState == "complete") {
            //                    hiddenMask();
            //                }
            //            }
            //BindCsInput();


        });

        function InitData()
        {
            InitFreezeTable();
            BindCsInput();
            if (<%=this.IsSave.ToString().ToLower()%>) {
            alert('保存完成');
            }
        }

        function InitFreezeTable()
        {
            var table = $("#MainTable");
            var tableId = table.attr('id');
            var freezeRowNum = table.attr('freezeRowNum');
            var freezeColumnNum = table.attr('freezeColumnNum');

            if (typeof (freezeRowNum) != 'undefined' || typeof (freezeColumnNum) != 'undefined') {
                freezeTable(table, freezeRowNum || 0, freezeColumnNum || 0, pageWidth(), pageHeight());

                var flag = false;
                $(window).resize(function () {
                    if (flag)
                        return;

                    setTimeout(function () {
                        adjustTableSize(tableId, pageWidth(), pageHeight());
                        flag = false;
                    }, 100);

                    flag = true;
                });
            }
        }

        function BindCsInput() {
            $(".csinput").change(function () {
                var rowIndex = $(this).attr("row");
                //alert(rowIndex);
                var total = 0;
                $("input[row=" + rowIndex + "]").each(function (i, n) {
                    total += parseFloat($(n).val());
                });

                var curTotal = $($("div[row_total=" + rowIndex + "]")[0]).html();
                //alert(curTotal);
                if (total > curTotal) {
                    alert("拆分总和不能大于成本值！");
                    $(this).focus();
                }
            });
        }
        InitData();
    </script>
    </form>
</body>
</html>
